home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / apps / 21 / emacsrc / keybind.c < prev    next >
Encoding:
C/C++ Source or Header  |  1986-05-14  |  10.6 KB  |  206 lines

  1. /*
  2.  * table binding keys to microEmacs functions
  3.  */
  4. #include "keynames.h"
  5.  
  6. typedef struct  {
  7.         short   k_code;                 /* Key code                     */
  8.         int     (*k_fp)();              /* Routine to handle it         */
  9. }       KEYBIND;
  10.  
  11. extern  int     ctrlg();                /* Abort out of things          */
  12. extern  int     quit();                 /* Quit                         */
  13. extern  int     ctlxlp();               /* Begin macro                  */
  14. extern  int     ctlxrp();               /* End macro                    */
  15. extern  int     ctlxe();                /* Execute macro                */
  16. extern  int     fileread();             /* Get a file, read only        */
  17. extern  int     filevisit();            /* Get a file, read write       */
  18. extern  int     filewrite();            /* Write a file                 */
  19. extern  int     filesave();             /* Save current file            */
  20. extern  int     filename();             /* Adjust file name             */
  21. extern  int     getccol();              /* Get current column           */
  22. extern  int     gotobol();              /* Move to start of line        */
  23. extern  int     forwchar();             /* Move forward by characters   */
  24. extern  int     gotoeol();              /* Move to end of line          */
  25. extern  int     backchar();             /* Move backward by characters  */
  26. extern  int     forwline();             /* Move forward by lines        */
  27. extern  int     backline();             /* Move backward by lines       */
  28. extern  int     forwpage();             /* Move forward by pages        */
  29. extern  int     backpage();             /* Move backward by pages       */
  30. extern  int     gotobob();              /* Move to start of buffer      */
  31. extern  int     gotoeob();              /* Move to end of buffer        */
  32. extern  int     setfillcol();           /* Set fill column.             */
  33. extern  int     setmark();              /* Set mark                     */
  34. extern  int     swapmark();             /* Swap "." and mark            */
  35. extern  int     forwsearch();           /* Search forward               */
  36. extern  int     backsearch();           /* Search backwards             */
  37. extern  int     showcpos();             /* Show the cursor position     */
  38. extern  int     nextwind();             /* Move to the next window      */
  39. extern  int     prevwind();             /* Move to the previous window  */
  40. extern  int     onlywind();             /* Make current window only one */
  41. extern  int     splitwind();            /* Split current window         */
  42. extern  int     mvdnwind();             /* Move window down             */
  43. extern  int     mvupwind();             /* Move window up               */
  44. extern  int     enlargewind();          /* Enlarge display window.      */
  45. extern  int     shrinkwind();           /* Shrink window.               */
  46. extern  int     listbuffers();          /* Display list of buffers      */
  47. extern  int     usebuffer();            /* Switch a window to a buffer  */
  48. extern  int     killbuffer();           /* Make a buffer go away.       */
  49. extern  int     reposition();           /* Reposition window            */
  50. extern  int     refresh();              /* Refresh the screen           */
  51. extern  int     twiddle();              /* Twiddle characters           */
  52. extern  int     tab();                  /* Insert tab                   */
  53. extern  int     newline();              /* Insert CR-LF                 */
  54. extern  int     indent();               /* Insert CR-LF, then indent    */
  55. extern  int     openline();             /* Open up a blank line         */
  56. extern  int     deblank();              /* Delete blank lines           */
  57. extern  int     quote();                /* Insert literal               */
  58. extern  int     backword();             /* Backup by words              */
  59. extern  int     forwword();             /* Advance by words             */
  60. extern  int     forwdel();              /* Forward delete               */
  61. extern  int     backdel();              /* Backward delete              */
  62. extern  int     kill();                 /* Kill forward                 */
  63. extern  int     yank();                 /* Yank back from killbuffer.   */
  64. extern  int     upperword();            /* Upper case word.             */
  65. extern  int     lowerword();            /* Lower case word.             */
  66. extern  int     upperregion();          /* Upper case region.           */
  67. extern  int     lowerregion();          /* Lower case region.           */
  68. extern  int     capword();              /* Initial capitalize word.     */
  69. extern  int     delfword();             /* Delete forward word.         */
  70. extern  int     delbword();             /* Delete backward word.        */
  71. extern  int     killregion();           /* Kill region.                 */
  72. extern  int     copyregion();           /* Copy region to kill buffer.  */
  73. /*
  74. extern  int     spawncli();             /* Run CLI in a subjob.         *
  75. extern  int     spawn();                /* Run a command in a subjob.   *
  76. */
  77. extern  int     quickexit();            /* low keystroke style exit.    */
  78.  
  79.  
  80. /*
  81.  * Command table.
  82.  * This table  is *roughly* in ASCII order, left to right across the
  83.  * characters of the command. This expains the funny location of the
  84.  * control-X commands.
  85.  */
  86. KEYBIND  keybind[] = {
  87.         CTRL|'@',               &setmark,
  88.         CTRL|'A',               &gotobol,
  89.         CTRL|'B',               &backchar,
  90. /*      CTRL|'C',               &spawncli, run CLI in subjob.   */
  91.         CTRL|'D',               &forwdel,
  92.         CTRL|'E',               &gotoeol,
  93.         CTRL|'F',               &forwchar,
  94.         CTRL|'G',               &ctrlg,
  95.         CTRL|'H',               &backdel,
  96.         CTRL|'I',               &tab,
  97.         CTRL|'J',               &indent,
  98.         CTRL|'K',               &kill,
  99.         CTRL|'L',               &refresh,
  100.         CTRL|'M',               &newline,
  101.         CTRL|'N',               &forwline,
  102.         CTRL|'O',               &openline,
  103.         CTRL|'P',               &backline,
  104.         CTRL|'Q',               "e,         /* Often unreachable    */
  105.         CTRL|'R',               &backsearch,
  106.         CTRL|'S',               &forwsearch,    /* Often unreachable    */
  107.         CTRL|'T',               &twiddle,
  108.         CTRL|'V',               &forwpage,
  109.         CTRL|'W',               &killregion,
  110.         CTRL|'Y',               &yank,
  111.         CTRL|'Z',               &quickexit,     /* quick save and exit  */
  112.  
  113.  
  114. F1,    &delbword,    /* delete preceding word            */
  115. F2,    &delfword,    /* delete the next/current word            */
  116. F3,    &kill,        /* kill current line to its end            */
  117. F4,    &yank,        /* insert the deleted stuff back        */
  118. F5,    &killbuffer,    /* kill [current] buffer; verifies if changed    */
  119. F6,     &listbuffers,    /* list buffers, and their sizes; not accurate    */
  120. F7,    &usebuffer,    /* switch to another existing/new buffer    */
  121. F8,    &filewrite,    /* save current buffer to specified file    */
  122. F9,    &filevisit,    /* read-in a file to edit            */
  123. F10,    &filesave,    /* save current buffer to its file        */
  124.  
  125. HELP,    &help,        /* alas, not much help yet!            */
  126. UNDO,   &quickexit,    /* quick save and exit                */
  127. INSERT,    &backpage,    /* display page preceding current one        */
  128. HOME,    &forwpage,    /* display page following current one        */
  129. UPARRO, &backline,    /* move cursor to preceding line; readjust displ*/
  130. DNARRO,    &forwline,    /* move cursor to next line; readjust display    */
  131. LTARRO,    &backchar,    /* move cursor to preceding char        */
  132. RTARRO,    &forwchar,    /* move cursor to following char        */
  133.  
  134. /*
  135. keypad keys
  136. -----------        */
  137. KLP,    &mvdnwind,    /* scroll window contents up (move window down)    */
  138. KRP,    &mvupwind,    /* scroll window contents dn (move window up)    */
  139. KSLASH,    &splitwind,    /* split current window into two        */
  140. KSTAR,    &onlywind,    /* make the current window the only one        */
  141. KMINUS,    &prevwind,    /* move cursor to preceding window, if any    */
  142. KPLUS,    &nextwind,    /* move cursor to following window, if any    */
  143. KENTER,    &ctlxe,        /* re-execute the key-board macro        */
  144. KDOT,    &swapmark,    /* swap mark with dot; (shift-F1 sets mark)    */
  145. K0,    &showcpos,    /* show cursor position numerically        */
  146.  
  147.  
  148. K7,    &gotobob,    /* move cursor to beginning of buffer        */
  149. K8,    &reposition,    /* reposition so that current line is at the top*/
  150. K9,    &gotoeob,    /* move cursor to end of buffer            */
  151. K4,    &backword,    /* move cursor to beginning of word        */
  152. K5,    &backline,    /* move to prev line; same as up arrow        */
  153. K6,    &forwword,    /* move cursor to end of word            */
  154. K1,    &gotobol,    /* move cursor to beginning of current line    */
  155. K2,    &forwline,    /* move to next line; same as dn arrow        */
  156. K3,    &gotoeol,    /* move cursor to end of current line        */
  157.         CTLX|CTRL|'B',          &listbuffers,
  158.         CTLX|CTRL|'C',          &quit,          /* Hard quit.           */
  159.         CTLX|CTRL|'F',          &filename,
  160.         CTLX|CTRL|'L',          &lowerregion,
  161.         CTLX|CTRL|'O',          &deblank,
  162.         CTLX|CTRL|'N',          &mvdnwind,
  163.         CTLX|CTRL|'P',          &mvupwind,
  164.         CTLX|CTRL|'R',          &fileread,
  165.         CTLX|CTRL|'S',          &filesave,      /* Often unreachable    */
  166.         CTLX|CTRL|'U',          &upperregion,
  167.         CTLX|CTRL|'V',          &filevisit,
  168.         CTLX|CTRL|'W',          &filewrite,
  169.         CTLX|CTRL|'X',          &swapmark,
  170.         CTLX|CTRL|'Z',          &shrinkwind,
  171. /*      CTLX|'!',               &spawn, Run 1 command.       */
  172.         CTLX|'=',               &showcpos,
  173.         CTLX|'(',               &ctlxlp,
  174.         CTLX|')',               &ctlxrp,
  175.         CTLX|'1',               &onlywind,
  176.         CTLX|'2',               &splitwind,
  177.         CTLX|'B',               &usebuffer,
  178.         CTLX|'E',               &ctlxe,
  179.         CTLX|'F',               &setfillcol,
  180.         CTLX|'K',               &killbuffer,
  181.         CTLX|'N',               &nextwind,
  182.         CTLX|'P',               &prevwind,
  183.         CTLX|'Z',               &enlargewind,
  184.         META|CTRL|'H',          &delbword,
  185.         META|'!',               &reposition,
  186.         META|'.',               &setmark,
  187.         META|'>',               &gotoeob,
  188.         META|'<',               &gotobob,
  189.         META|'B',               &backword,
  190.         META|'C',               &capword,
  191.         META|'D',               &delfword,
  192.         META|'F',               &forwword,
  193.         META|'L',               &lowerword,
  194.         META|'U',               &upperword,
  195.         META|'V',               &backpage,
  196.         META|'W',               ©region,
  197.         META|0x7F,              &delbword,
  198.         0x7F,                   &backdel
  199. };
  200.  
  201. #define NKEYBIND (sizeof(keybind)/sizeof(keybind[0]))
  202.  
  203. int    nkeybind    = NKEYBIND;
  204.  
  205. /* -eof- */
  206.